package com.dao.redis.imp;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.data.redis.serializer.RedisSerializer;

/**
 * 抽象的内存数据库基类
 * 
 * @author 尚业
 *
 * @param <K>
 * @param <V>
 */
public class AbstractBaseRedisDao<K, V> {
	@Autowired
	protected RedisTemplate<K, V> redisTemplate;
	
	/** 
     * 设置redisTemplate 
     * @param redisTemplate the redisTemplate to set 
     */  
    public void setRedisTemplate(RedisTemplate<K, V> redisTemplate) { 
        this.redisTemplate = redisTemplate;  
    }  
      
    /** 
     * 获取 StringRedisSerializer 
     * <br>------------------------------<br> 
     */  
    protected RedisSerializer<String> getStringRedisSerializer() {  
        return redisTemplate.getStringSerializer();  
    }
    
    protected ValueOperations<K, V> getVRedisSerializer() {  
        return redisTemplate.opsForValue();
    }
}
